package com.nuvo.services;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import com.nuvo.entities.Menu;
import com.nuvo.entities.MenuTipousuario;
import com.nuvo.entities.Tipousuario;


@Stateless
public class MenuTipousuarioService extends AbstractService<MenuTipousuario> {
    @PersistenceContext(unitName = "LicoresNuvoPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public MenuTipousuarioService() {
        super(MenuTipousuario.class);
    }

    public Boolean findByMenuAndTipousuario(Menu menu, Tipousuario tipo) {
        try {
            Query query = em.createNamedQuery("MenuTipousuario.findByMenuAndTipousuario");
            query.setParameter("menu", menu);
            query.setParameter("tipo", tipo);
            query.getSingleResult();
            return true;
        }
        catch (Exception e) { return false; }
    } 


}
